package hdoj;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

//营救Angel，但是出发点可能有多个
public class MazeHDU1242 {

	private static final int[][] dir = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
	
	private static final char START = 'r';
	private static final char OBSTACLE = '#';
	private static final char EXIT = 'a';
	private static final char GUARD = 'x';
	
	private static final int MAX = 202;
	
	private int minMinute = Integer.MAX_VALUE;
	
	private int rows, columns;
	
	private char[][] maze = new char[MAX][MAX];
	
	private boolean[][] visited = new boolean[MAX][MAX];
	
	public static void main(String[] args) {
		MazeHDU1242 object = new MazeHDU1242();
		object.getRes();
	}
	
	private class Point{
		int x; int y;
		Point(int x, int y){
			this.x = x;
			this.y = y;
		}
	}
	
	//不知道是不是一个一个试
	public void getRes(){
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			minMinute = Integer.MAX_VALUE;
			rows = scanner.nextInt();
			columns = scanner.nextInt();
			if(rows == 0 && columns == 0){
				break;
			}
			List<Point> list = new ArrayList<>();
			for(int i = 0; i < rows; i++){
				String str = scanner.next();
				for(int j = 0; j < columns; j++){
					if(str.charAt(j) == START){
						list.add(new Point(i, j));
					}
					maze[i][j] = str.charAt(j);
				}
			}
			for (Point point : list) {
				bfs(point.x, point.y);
			}
			if(minMinute == Integer.MAX_VALUE){
				System.out.println("Poor ANGEL has to stay in the prison all his life.");
			}else{
				System.out.println(minMinute);
			}
		}
		scanner.close();
	}
	
	public static Comparator<Node> nodeComparator = new Comparator<Node>(){
        @Override
        public int compare(Node c1, Node c2) {
            return (int) (c1.minute - c2.minute);
        }
    };
	
	private class Node{
		int x; int y;
		int minute;
		public Node() {
		}
		public Node(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	
	//Runtime 436MS
	public void bfs(int x, int y){
		PriorityQueue<Node> queue = new PriorityQueue<>(nodeComparator);
		Node temp = new Node(x, y);
		queue.add(temp);
		for (int i = 0; i < rows; i++) {
			for (int j = 0; j < columns; j++) {
				visited[i][j] = false;
			}
		}
		visited[x][y] = true;
		while(!queue.isEmpty()){
			temp = queue.poll();
			if(maze[temp.x][temp.y] == EXIT){
				minMinute = Math.min(minMinute, temp.minute);
				return;
			}
			for(int i = 0; i < dir.length; i++){
				int curX = temp.x + dir[i][0];
				int curY = temp.y + dir[i][1];
				if(curX < 0 || curX >= rows || curY < 0 || curY >= columns || maze[curX][curY] == OBSTACLE
						|| visited[curX][curY]){
					continue;
				}
				Node next = new Node(curX, curY);
				next.minute = temp.minute + 1;
				if(maze[curX][curY] == GUARD){
					next.minute++;
				}
				visited[curX][curY] = true;
				queue.add(next);
			}
		}
	}
}
